/**
 * Created by hejg on 2018/5/28.
 */
import {observable, computed, action} from 'mobx';
import Style from '../../../components/Style';

export default class RankedPartStore {
    @observable
    selectPeriod = 0;//默认选中账期的第1个下标
    @observable
    periodOptions = [];//可供选择的账期列表
    @observable
    selectIndex = [0, 0];//默认选中指标(index=0)和指标小项(index=1)的第1个下标
    @observable
    indexOptions = [];//可供选择的指标列表及小项列表的多层结构
    @observable
    screenData = [];//当前页面的核心数据
    @observable
    indicatorVisible = true;//是否启用加载框
    @observable
    indicatorMessage = '';//显示在加载框的文字信息
    @observable
    params = {indexCode: '', childCode: '', opTime: ''};//页面的查询条件

    @computed
    get selectIndexTitle() {
        if (this.indexOptions.length > 0) {
            return this.indexOptions[this.selectIndex[0]].indexName;
        } else {
            return '正在加载指标';
        }
    }

    @action
    setSelectPeriod(index) {//设置选中账期的下标
        this.selectPeriod = index;
    }

    @action
    setSelectIndex(array) {//设置选中指标的下标
        this.selectIndex = array;
    }

    @action
    setPeriodOptions = (items) => {//设置账期列表数据集
        let periods = new Array();
        for (let i = 0; i < items.length; i++) {
            periods.push({label: items[i], value: items[i]});
        }
        this.periodOptions = periods;
    }

    @action
    setIndexOptions = (items) => {//设置指标列表数据集
        this.indexOptions = items;
    }

    @action
    setScreenData = (data) => {//设置屏幕核心数据
        this.screenData = data;
    }

    @action
    showIndicator = (message) => {//启用加载效果
        this.indicatorVisible = true;
        if (message) {
            this.indicatorMessage = message;
        }
    }

    @action
    hiddenIndicator() {//关闭加载效果
        this.indicatorVisible = false;
    }

    @action
    setParams = (params) => {//设置查询条件
        this.params = params;
    }
}